import {
	RouterMount,
	createRouter,
	runtimeQuit
} from './uni-simple-router.js';

let first = null;
const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,
	APP: {
		animation: {
			animationType: 'slide-in-top',
			animationDuration: 300
		}
	},
	routerBeforeEach: (to, from, next) => {
		next();
	},
	routerAfterEach: (to, from) => {},
	routerErrorEach: ({
		type,
		msg
	}) => {
		console.log({
			type,
			msg
		});
		router.$lockStatus = false;
		// #ifdef APP-PLUS
		if (type === 3) {
			runtimeQuit();
		}
		// #endif
	},
	debugger: true,
	routes: [
		...ROUTES,
		{
			path: '*',
			redirect: (to) => {
				return {
					name: '404'
				}
			}
		},
	]
});
/* 路由前置守卫 */
router.beforeEach((to, from, next) => {
	next();
});
/* 路由后置守卫 */
router.afterEach((to, from, next) => {
	console.log('afterEach---跳转结束')
});

export {
	router,
	RouterMount
}
